package com.tsmti.system.service.impl;

import com.tsmti.core.common.service.impl.BaseServiceImpl;
import com.tsmti.system.entity.MessageProperty;
import com.tsmti.system.service.MessagePropertyService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Package：com.tsmti.system.service.impl
 * @Class：MessagePropertyServiceImpl
 * @Description： TODO
 * @Author：zcw
 * @Date：Created in 2018/5/30 16:19
 * @Company:
 * @Version：
 * @Modified By:
 */
@Service("messageProperty")
public class MessagePropertyServiceImpl  extends BaseServiceImpl<MessageProperty> implements MessagePropertyService {
    /**
     * 判断标签是否存在
     * @return
     */
    @Override
    public List<MessageProperty> getExistList(MessageProperty messageProperty) {
        if(messageProperty.getId() == null){
            return findByHql(" from MessageProperty where locale = ? and (code = ? or labelName= ?)",messageProperty.getLocale(),messageProperty.getCode(),messageProperty.getLabelName());
        }
        return findByHql(" from MessageProperty where id <> ? and locale = ? and (code = ? or labelName= ?)",messageProperty.getId(),
                messageProperty.getLocale(),messageProperty.getCode(),messageProperty.getLabelName());
    }
}
